from coin.strategy.mm.subscription import SubscriptionRequest
from coin.strategy.accounting.pnl_balance_printer.pnl_balance_printer import SpotPnlBalancePrinter
from coin.strategy.accounting.pnl_balance_printer.bitmex.pnl_balance_printer import BitmexPnlBalancePrinter
from coin.strategy.accounting.pnl_balance_printer.huobi_futures.pnl_balance_printer import HuobiFuturesPnlBalancePrinter
from coin.strategy.accounting.pnl_balance_printer.okex_futures.pnl_balance_printer import OkexFuturesPnlBalancePrinter
from coin.strategy.accounting.pnl_balance_printer.bitflyer_futures.pnl_balance_printer import BitflyerFuturesPnlBalancePrinter
from coin.strategy.accounting.pnl_balance_printer.kraken_futures.pnl_balance_printer import KrakenFuturesPnlBalancePrinter
from coin.strategy.accounting.pnl_balance_printer.quoinex.pnl_balance_printer import QuoinexPnlBalancePrinter
from coin.strategy.accounting.pnl_balance_printer.deribit_futures.pnl_balance_printer import DeribitFuturesPnlBalancePrinter
from coin.strategy.accounting.pnl_balance_printer.binance_futures.pnl_balance_printer import BinanceFuturesPnlBalancePrinter


def get_pnl_balance_printer_cls(sub_req):
  assert isinstance(sub_req, SubscriptionRequest)
  printer = None
  if sub_req.market_type == 'Spot' and \
     sub_req.exchange in (
         'Binance', 'Bitflyer', 'Bithumb', 'Bitstamp', 'Huobi', 'Korbit',
         'Kraken', 'Okex', 'Upbit', 'Gdax', 'Coinone', 'Gopax', 'Uniswap'):
    printer = SpotPnlBalancePrinter
  elif sub_req.exchange in ('Quoinex'):
    printer = QuoinexPnlBalancePrinter
  elif sub_req.market_type == 'Futures' and sub_req.exchange == 'Bitmex':
    printer = BitmexPnlBalancePrinter
  elif sub_req.market_type == 'Futures' and sub_req.exchange == 'Huobi':
    printer = HuobiFuturesPnlBalancePrinter
  elif sub_req.market_type == 'Futures' and sub_req.exchange == 'Okex':
    printer = OkexFuturesPnlBalancePrinter
  elif sub_req.market_type == 'Futures' and sub_req.exchange == 'Bitflyer':
    printer = BitflyerFuturesPnlBalancePrinter
  elif sub_req.market_type == 'Futures' and sub_req.exchange == 'Kraken':
    printer = KrakenFuturesPnlBalancePrinter
  elif sub_req.market_type == 'Futures' and sub_req.exchange == 'Deribit':
    printer = DeribitFuturesPnlBalancePrinter
  elif sub_req.market_type == 'Futures' and sub_req.exchange == 'Binance':
    printer = BinanceFuturesPnlBalancePrinter
  else:
    raise ValueError('Unknown sub_req: %s' % sub_req)
  return printer
